#include "OrdOutputs.h"
#include "..\System\F2806x_Device.h"

bool OrdOutputs::Init()
{
	// Configure GPIO32 as a GPIO output pin
	EALLOW;

	//  GPIO-32 - PIN FUNCTION = O1
	GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 0;	// 0=GPIO
	GpioDataRegs.GPBCLEAR.bit.GPIO32 = 1;	// uncomment if --> Set Low initially
	GpioCtrlRegs.GPBDIR.bit.GPIO32 = 1;		// 1=OUTput,  0=INput 
	
	//  GPIO-33 - PIN FUNCTION = O2
	GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 0;	// 0=GPIO
	GpioDataRegs.GPBCLEAR.bit.GPIO33 = 1;	// uncomment if --> Set Low initially
	GpioCtrlRegs.GPBDIR.bit.GPIO33 = 1;		// 1=OUTput,  0=INput
	
	//  GPIO-32 - PIN FUNCTION = O3
	GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 0;	// 0=GPIO
	GpioDataRegs.GPACLEAR.bit.GPIO22 = 1;	// uncomment if --> Set Low initially
	GpioCtrlRegs.GPADIR.bit.GPIO22 = 1;		// 1=OUTput,  0=INput
	
 	EDIS;
 	
	return true;
}

void OrdOutputs::Set(eOutput out)
{
	if( out == O1) GpioDataRegs.GPBSET.bit.GPIO32 = 1;
	else if( out == O2 ) GpioDataRegs.GPBSET.bit.GPIO33 = 1;
	else if( out == O3 ) GpioDataRegs.GPASET.bit.GPIO22 = 1;
}

void OrdOutputs::Reset(eOutput out)
{
	if( out == O1) GpioDataRegs.GPBCLEAR.bit.GPIO32 = 1;
	else if( out == O2 ) GpioDataRegs.GPBCLEAR.bit.GPIO33 = 1;
	else if( out == O3 ) GpioDataRegs.GPACLEAR.bit.GPIO22 = 1;
}
